import 'package:dio/dio.dart';

// void main() {
//
//   //异步回调then
//   Dio dio = new Dio();
//   dio.get('https://wpapi.ducafecat.tech/products/categories').then((respone) {
//     print(respone.data);
//   });
// }

//异步等待 await
// void main() async {
//   Dio dio = Dio();
//   Response<String> response =
//   await dio.get("https://wpapi.ducafecat.tech/products/categories");
//   print(response.data);
// }

//异步返回值
Future<String?> getUrl(String url) async {
  Dio dio = Dio();
  Response<String> response = await dio.get(url);
  return response.data;
}

void main() async {
  var content =
  await getUrl('https://wpapi.ducafecat.tech/products/categories');
  print(content);
}